<template>
  <el-dialog :visible.sync="visible" title="编辑操作日志" width="600px">
    <el-form :model="form" label-width="100px" ref="formRef">
      <el-form-item label="操作人" prop="poperationUser">
        <el-input v-model="form.poperationUser" placeholder="请输入操作人"></el-input>
      </el-form-item>
      <el-form-item label="操作对象" prop="operationObject">
        <el-input v-model="form.operationObject" placeholder="请输入操作对象"></el-input>
      </el-form-item>
      <el-form-item label="操作类型" prop="operationType">
        <el-input v-model="form.operationType" placeholder="请输入操作类型"></el-input>
      </el-form-item>
      <el-form-item label="操作时间" prop="operationTime">
        <el-date-picker
          v-model="form.operationTime"
          type="datetime"
          placeholder="选择操作时间"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="操作结果" prop="operationStatus">
        <el-input v-model="form.operationStatus" placeholder="请输入操作结果"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="close">取消</el-button>
      <el-button type="primary" @click="submit">保存</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: "operateitem",
  data() {
    return {
      visible: false,
      form: {
        poperationUser: "",
        operationObject: "",
        operationType: "",
        operationTime: "",
        operationStatus: "",
      }, // 初始化为空的表单数据
    };
  },
  methods: {
    open() {
      this.visible = true; // 打开弹出层
    },
    close() {
      this.visible = false; // 关闭弹出层
      this.resetForm(); // 重置表单数据
    },
    submit() {
      if (!this.form.poperationUser || !this.form.operationObject) {
        this.$message.error("请填写完整信息");
        return;
      }
      this.$emit("submit", this.form); // 提交表单数据
      this.close();
    },
    resetForm() {
      this.form = {
        poperationUser: "",
        operationObject: "",
        operationType: "",
        operationTime: "",
        operationStatus: "",
      }; // 重置表单数据为空
    },
  },
};
</script>

<style scoped>
.dialog-footer {
  text-align: right;
}
</style>